import 'package:flutter_nb_net/flutter_net.dart';

class CardPackagesResp extends BaseNetModel {
  int? code;
  String? msg;
  CardPackagesData? data;

  CardPackagesResp({this.code, this.msg, this.data});

  @override
  fromJson(Map<String, dynamic> json) {
    return CardPackagesResp(
      code: json['code'],
      msg: json['msg'],
      data: json['data'] == null ? null : CardPackagesData().fromJson(json['data']),
    );
  }
}

class CardPackagesData extends BaseNetModel {
  String? iccid;
  String? cardNo;
  PackageInfo? mainPackageInfo;
  List<PackageInfo>? additionalPackageInfo;

  CardPackagesData({this.iccid, this.cardNo, this.mainPackageInfo, this.additionalPackageInfo});

  @override
  fromJson(Map<String, dynamic> json) {
    return CardPackagesData(
      iccid: json['iccid'],
      cardNo: json['cardNo'],
      mainPackageInfo: json['mainPackageInfo'] == null ? null : PackageInfo().fromJson(json['mainPackageInfo']),
      additionalPackageInfo: json['additionalPackageInfo'] == null ? null : List<PackageInfo>.from(json['additionalPackageInfo'].map((x) => PackageInfo().fromJson(x))),
    );

  }
}

class PackageInfo extends BaseNetModel {
  num? packageId;
  int? packageType;

  String? packageCode;
  num? price;
  double? consumption;
  String? packageName;
  int? timeLength;
  String? timeUnit;

  PackageInfo({this.packageCode, this.price, this.consumption, this.packageName, this.timeLength, this.timeUnit, this.packageId, this.packageType});

  @override
  fromJson(Map<String, dynamic> json) {
    return PackageInfo(
      packageCode: json['packageCode'],
      price: json['price'],
      consumption: json['consumption'],
      packageName: json['packageName'],
      timeLength: json['timeLength'],
      timeUnit: json['timeUnit'],
      packageId: json['packageId'],
      packageType: json['packageType'],
    );
  }

  Map<String, dynamic> toJson() => {
    "packageCode": packageCode,
    "price": price,
    "consumption": consumption,
    "packageName": packageName,
    "timeLength": timeLength,
    "timeUnit": timeUnit,
    "packageId": packageId,
    "packageType": packageType,
  };
}